home *** CD-ROM | disk | FTP | other *** search
- ' Program HEADERS - Version 4.01
- '
- ' DATE: April 28, 1986
- ' TIME: 7:45 a.m.
- '
- ' Placed in the Public Domain by software, etc.
- '
- ' Documentation..........HEADERS.DOC
- ' Modular BASIC source...HEADERS.MB
- ' Translation table......HEADERS.TBL
- ' BASIC source...........HEADERS.BAS
- ' Executeable program....HEADERS.EXE
- '
- ' Environment:
- ' Must be compatible with hardware/software below. To obtain
- ' 99, 108, 132 or 165 lines/page, a Graphics Printer is required.
- '
- ' Hardware: IBM PC/XT/AT with 80 CPS Matrix or Graphics Printer
- ' Software: IBM PC-DOS 2.10, 3.00, 3.10, or 3.20
- '
- ' Please send comments or questions to:
- '
- ' software, etc.
- ' P.O. Box 25469
- ' Rochester, NY 14625
-
- DEFINT A-Z
- ON ERROR GOTO ErrorHandler@
-
-
- DEF fnNumberField(s$,Description$)
- LocEqualSign = INSTR(s$,"=")
- If LocEqualSign < 2 OR LocEqualSign = LEN(s$)
- PRINT "Invalid ";Description$;" - ";s$
- SYSTEM
- EndIf
- n$ = RIGHT$(s$,LEN(s$)-LocEqualSign)
- If 1 <= FIX(VAL(n$)) AND FIX(VAL(n$)) <= 32767
- fnNumberField = FIX(VAL(n$))
- ElseIf n$ = "0"
- fnNumberField = 0
- Else
- PRINT "Invalid number for ";Description$;" - ";FIX(VAL(n$))
- SYSTEM
- EndIf
- END DEF
-
- DEF fnValidPage = (BeginningPage <= CurrentPage AND CurrentPage <= EndingPage)
-
- DEF fnNumber$(x) = MID$(STR$(x),2,LEN(STR$(x))-1)
-
-
- InitializeProgram
- InitializePrinter
- PrintFile
- RestorePrinter
-
- SYSTEM
-
-
-
- Procedure InitializeProgram
- FALSE = 0: TRUE = NOT FALSE
- InputChannel = 1
- OutputChannel = 2
- BreakDetected = FALSE
-
- CtrlC$ = CHR$( 3)
- ht$ = CHR$( 9)
- lf$ = CHR$(10)
- ff$ = CHR$(12)
- cr$ = CHR$(13)
- esc$ = CHR$(27)
- sp$ = " "
-
- KEY OFF
- WIDTH 80
- COLOR 7,0
- CLS
-
- cmd$ = COMMAND$
- If LEN(cmd$) = 0
- GiveInstructions
- SYSTEM
- EndIf
- PRINT "Version 4.01 HEADERS ";cmd$
- PRINT
- GetHeaderData
- GetFileNameAndOpt
- OpenInputFile
- ParseOpt
- EndProcedure
-
-
-
- Procedure GiveInstructions
- CLS
- PRINT " HEADERS Version 4.01 - Command Summary"
- PRINT "SET HEADER1=Something for left part of header (optional)"
- PRINT "SET HEADER2=Something for center part of header (optional)"
- PRINT "HEADERS FileName/W=www,L=lll,R=rrr,H=hhh,G=ggg,D,S=sss,B=bbb,E=eee"
- PRINT " | | | | | | | | |"
- PRINT "Width____________| | | | | | | | |"
- PRINT "Left margin size_______| | | | | | | |"
- PRINT "Right margin size____________| | | | | | |"
- PRINT "Height (lines/page)________________| | | | | |"
- PRINT "Gap between pages (blank lines)__________| | | | |"
- PRINT "Double Strike__________________________________| | | |"
- PRINT "Spacing (e.g, S=2 means double-space)____________| | |"
- PRINT "Beginning page_________________________________________| |"
- PRINT "Ending page__________________________________________________|"
- PRINT
- PRINT "DEFAULTS: W=80 L=0 R=0 H=66 G=6 S=1 B=1 E=32767"
- PRINT " Double-strike used only for H=99, 108, 132, or 165."
- PRINT " Otherwise, use option D to obtain double-strike."
- PRINT "W must be set to 40, 66, 80, or 132"
- PRINT "H must be set to 11, 22, 33, 44, 66, 88, 99, 108, 132, or 165."
- PRINT " Graphics Printer required for 99, 108, 132, or 165."
- PRINT "Continuation lines not used unless L > 0"
- EndProcedure
-
-
-
- Procedure GetHeaderData
- LeftSide$ = ENVIRON$("HEADER1")
- Middle$ = ENVIRON$("HEADER2")
- HeaderNeeded = (LEN(LeftSide$) + LEN(Middle$) > 0)
- If HeaderNeeded
- t$ = LeftSide$
- CALL Capitalize(t$)
- If t$ = "DATE"
- LeftSide$ = DATE$
- ElseIf t$ = "TIME"
- LeftSide$ = TIME$
- ElseIf t$ = "DATE,TIME"
- LeftSide$ = DATE$ + " at " + TIME$
- ElseIf t$ = "TIME,DATE"
- LeftSide$ = TIME$ + " " + DATE$
- EndIf
- EndIf
- EndProcedure
-
-
-
- Procedure GetFileNameAndOpt
- '
- ' HEADERS FileName/Opt
- '
- LocSlash = INSTR(cmd$,"/")
- If LocSlash = 0
- FileName$ = cmd$
- Opt$ = ""
- Else
- FileName$ = LEFT$(cmd$,LocSlash-1)
- Opt$ = RIGHT$(cmd$,LEN(cmd$)-LocSlash)
- EndIf
- EndProcedure
-
-
-
- Procedure OpenInputFile
- If LEN(FileName$) = 0
- GiveInstructions
- SYSTEM
- EndIf
- HeaderName$=FileName$
- If MID$(HeaderName$,2,1)=":" 'Remove drive spec for use in header
- HeaderName$=MID$(HeaderName$,3,len(HeaderName$)-2)
- EndIf
- ON ERROR GOTO FileNotFound@
- OPEN "Input",#InputChannel,FileName$
- ON ERROR GOTO ErrorHandler@
- EndProcedure
-
-
-
- FileNotFound@
- PRINT: PRINT "Sorry, but your file cannot be opened."
- CALL BASICErr(ErrorMsg$)
- PRINT ErrorMsg$
- SYSTEM
-
-
-
- Procedure ParseOpt
- '
- ' Set up default options
- '
- CharactersPerLine = 80
- MarginSize = 0
- RightMarginSize = 0
-
- LinesPerPage = 66
- InterPageGap = 6
- BlankLineCount = 0
-
- BeginningPage = 1
- EndingPage = 32767
-
- WidthSpecified = FALSE
- MarginSpecified = FALSE
- RightMarginSpecified = FALSE
- HeightSpecified = FALSE
- GapSpecified = FALSE
- DoubleStrikeSpecified = FALSE
- SpacingSpecified = FALSE
- BeginningPageSpecified = FALSE
- EndingPageSpecified = FALSE
-
- CALL Replace(Opt$,",",sp$) 'Replace commas with spaces
- CALL Replace(Opt$,ht$,sp$) 'Replace tabs with spaces
- CALL Replace(Opt$,sp$+sp$,sp$) 'Replace multiple spaces with space
- Loop
- If LEN(Opt$) = 0
- ExitLoop
- Else
- LocSpace = INSTR(Opt$,sp$)
- If LocSpace = 0
- CurrentOpt$ = Opt$
- Opt$ = ""
- Else
- CurrentOpt$ = LEFT$(Opt$,LocSpace-1)
- Opt$ = RIGHT$(Opt$,LEN(Opt$)-LocSpace)
- EndIf
-
- IF LEFT$(CurrentOpt$,2) = "W="
- If WidthSpecified
- CALL RedefinedError("Characters per line")
- Else
- WidthSpecified = TRUE
- CharactersPerLine = fnNumberField(CurrentOpt$,"Characters per line")
- EndIf
-
- ElseIf LEFT$(CurrentOpt$,2) = "L="
- If MarginSpecified
- CALL RedefinedError("Left margin")
- Else
- MarginSpecified = TRUE
- MarginSize = fnNumberField(CurrentOpt$,"Left margin")
- EndIf
-
- ElseIf LEFT$(CurrentOpt$,2) = "R="
- If RightMarginSpecified
- CALL RedefinedError("Right margin")
- Else
- RightMarginSpecified = TRUE
- RightMarginSize = fnNumberField(CurrentOpt$,"Right margin")
- EndIf
-
- ElseIf LEFT$(CurrentOpt$,2) = "H="
- If HeightSpecified
- CALL RedefinedError("Lines per page")
- Else
- HeightSpecified = TRUE
- LinesPerPage = fnNumberField(CurrentOpt$,"Lines per page")
- EndIf
-
- ElseIf LEFT$(CurrentOpt$,2) = "G="
- If GapSpecified
- CALL RedefinedError("Interpage gap")
- Else
- GapSpecified = TRUE
- InterpageGap = fnNumberField(CurrentOpt$,"Interpage gap")
- EndIf
-
- ElseIf LEFT$(CurrentOpt$,2) = "S="
- If SpacingSpecified
- CALL RedefinedError("Spacing")
- Else
- SpacingSpecified = TRUE
- BlankLineCount = fnNumberField(CurrentOpt$,"Spacing")-1
- EndIf
-
- ElseIf LEFT$(CurrentOpt$,2) = "B="
- If BeginningPageSpecified
- CALL RedefinedError("Beginning page")
- Else
- BeginningPageSpecified = TRUE
- BeginningPage = fnNumberField(CurrentOpt$,"Beginning page")
- EndIf
-
- ElseIf LEFT$(CurrentOpt$,2) = "E="
- If EndingPageSpecified
- CALL RedefinedError("Ending page")
- Else
- EndingPageSpecified = TRUE
- EndingPage = fnNumberField(CurrentOpt$,"Ending page")
- EndIf
-
- ElseIf CurrentOpt$ = "D"
- If DoubleStrikeSpecified
- CALL RedefinedError("Double strike")
- Else
- DoubleStrikeSpecified = TRUE
- EndIf
-
- Else
- PRINT "Unrecognized option - ";CurrentOpt$
- SYSTEM
- EndIf
- EndIf
- EndLoop
-
- If BeginningPage > EndingPage
- PRINT "Beginning page =";STR$(BeginningPage)
- PRINT "Ending page =";STR$(EndingPage)
- PRINT "Nothing to print."
- RestorePrinter
- SYSTEM
- EndIf
- EndProcedure
-
-
-
- SUB Replace(s$,Old$,New$) STATIC
- STATIC LengthOld,LocOld,l$,r$
- LengthOld = LEN(Old$)
- If LengthOld = 0
- EXIT SUB
- EndIf
- Loop
- ExitLoop IF LEN(s$) = 0
- LocOld = INSTR(s$,Old$)
- ExitLoop IF LocOld = 0
- l$ = LEFT$(s$,LocOld-1)
- r$ = RIGHT$(s$,LEN(s$)-(LocOld+LengthOld-1))
- s$ = l$ + New$ + r$
- EndLoop
- END SUB
-
-
-
- SUB RedefinedError(s$) STATIC
- PRINT "Option defined more than once - ";s$
- SYSTEM
- END SUB
-
-
-
- Procedure PrintFile
- PRINT "Lines per page....";STR$(LinesPerPage)
- PRINT "Interpage gap.....";STR$(InterpageGap)
- PRINT "Line width........";STR$(CharactersPerLine)
- IF MarginSize > 0 THEN PRINT "Left margin.......";STR$(MarginSize)
- IF RightMarginSize > 0 THEN PRINT "Right margin......";STR$(RightMarginSize)
- IF BeginningPage > 1 THEN PRINT "Beginning page...";STR$(BeginningPage)
- IF EndingPage < 32767 THEN PRINT "Ending page......";STR$(EndingPage)
- IF LEN(LeftSide$) > 0 THEN PRINT "HEADER1: ";LeftSide$
- IF LEN(Middle$) > 0 THEN PRINT "HEADER2: ";Middle$
- IF NOT HeaderNeeded THEN PRINT "Header lines not used"
- If BlankLineCount <= 0
- PRINT "Single spacing"
- ElseIf BlankLineCount = 1
- PRINT "Double spacing"
- ElseIf BlankLineCount = 2
- PRINT "Triple spacing"
- Else
- PRINT "Inserting";STR$(BlankLineCount);
- PRINT " blank lines after each line of text"
- EndIf
- IF DoubleStrikeSpecified THEN PRINT "Double strike active"
-
- CurrentPage = 0
- PrintHeader
- WHILE (CurrentPage <= EndingPage) AND NOT EOF(InputChannel)
- CheckForBreak
- If BreakDetected
- BreakDetected = FALSE
- HandleBreak
- EndIf
- ReadLine
- PrintLine
- WEND
- CLOSE InputChannel
-
- EjectPage
- EndProcedure
-
-
-
- Procedure CheckForBreak
- Repeat
- t$ = INKEY$
- IF t$ = CtrlC$ THEN BreakDetected = TRUE
- Until LEN(t$) = 0
- EndProcedure
-
-
-
- Procedure HandleBreak
- ReturnMsg$ = " Return to DOS? (y/n) "
- PRINT: COLOR 0,7: PRINT ReturnMsg$;: COLOR 7,0: LOCATE ,,1
- Repeat
- Repeat
- t$ = INKEY$
- Until LEN(t$) = 1
- CALL Capitalize(t$)
- Until t$ = "Y" OR t$ = "N"
- If t$ = "Y"
- PRINT
- EjectPage
- RestorePrinter
- SYSTEM
- Else
- LOCATE ,1,0: PRINT SPACE$(LEN(ReturnMsg$));: LOCATE ,1,0
- EndIf
- EndProcedure
-
-
-
- Procedure PrintLeftMargin
- IF MarginSize > 0 THEN PRINT# OutputChannel,SPACE$(MarginSize);
- EndProcedure
-
-
-
- Procedure PrintOverflowMargin
- If MarginSize > 2
- PRINT# OutputChannel,SPACE$(MarginSize-2);"| ";
- ElseIf MarginSize = 2
- PRINT# OutputChannel,"| ";
- ElseIf MarginSize = 1
- PRINT# OutputChannel,"|";
- EndIf
- EndProcedure
-
-
-
- Procedure PrintHeader
- CurrentPage=CurrentPage+1
- LinesLeft = AvailableLines
- If HeaderNeeded
- If fnValidPage
- PRINT# OutputChannel,CheckPaperEnd$;
- BuildHeaderLine$
- PrintLeftMargin
- PRINT# OutputChannel,HeaderLine$;NewLine$;
- PrintLeftMargin
- PRINT# OutputChannel,STRING$(AvailableSpace,"-");NewLine$;
- PRINT# OutputChannel,IgnorePaperEnd$;
- EndIf
- LinesLeft=LinesLeft-2
- EndIf
- EndProcedure
-
-
-
- Procedure BuildHeaderLine$
- Page$ = "-" + fnNumber$(CurrentPage) + "-"
- RightSide$ = HeaderName$ + sp$ + Page$
- Room = AvailableSpace - (LEN(LeftSide$) + LEN(Middle$) + LEN(RightSide$))
- If Room >= 2 'Need at least one space on each side of Middle$
- Gap1$ = SPACE$(Room \ 2)
- Gap2$ = SPACE$(Room - LEN(Gap1$))
- HeaderLine$ = LeftSide$ + Gap1$ + Middle$ + Gap2$ + RightSide$
- ExitProcedure
- EndIf
-
- Room = AvailableSpace - (LEN(LeftSide$) + LEN(RightSide$))
- If Room >= 1 'Need at least one space between LeftSide$ and RightSide$
- HeaderLine$ = LeftSide$ + SPACE$(Room) + RightSide$
- ExitProcedure
- EndIf
-
- Room = AvailableSpace - (LEN(Middle$) + LEN(RightSide$))
- If Room >= 1 'Need at least one space between Middle$ and RightSide$
- HeaderLine$ = Middle$ + SPACE$(Room) + RightSide$
- ExitProcedure
- EndIf
-
- Room = AvailableSpace - LEN(RightSide$)
- If Room = 0
- HeaderLine$ = RightSide$
- ExitProcedure
- ElseIf Room > 0
- HeaderLine$ = SPACE$(Room) + RightSide$
- ExitProcedure
- EndIf
-
- Room = AvailableSpace - LEN(Page$)
- If Room = 0
- HeaderLine$ = Page$
- ExitProcedure
- ElseIf Room > 0
- HeaderLine$ = SPACE$(Room) + Page$
- ExitProcedure
- EndIf
-
- 'No room for even the page number!
- 'Risk abort if AvailableSpace = 0. Nothing else would work anyway.
-
- HeaderLine$ = STRING$(AvailableSpace,"?")
- EndProcedure
-
-
-
- Procedure ReadLine
- LINE INPUT# InputChannel,Text$
- CALL Replace(Text$,lf$+cr$,sp$) 'Replace linefeed/return with space
- CALL Replace(Text$,lf$,sp$) 'Replace isolated linefeed with space
- CALL Replace(Text$,ff$,"") 'Eliminate formfeeds
- HandleTabs 'Replace horizontal tabs with spaces
- RemoveTrailingWhiteSpace
- EndProcedure
-
-
-
- Procedure HandleTabs
- ExitProcedure IF LEN(Text$) = 0
- Loop
- TabSpot = INSTR(Text$,ht$)
- ExitLoop IF TabSpot = 0
- L$ = LEFT$(Text$,TabSpot-1) + sp$
- R$ = RIGHT$(Text$,LEN(Text$)-TabSpot)
- WHILE 0 <> (LEN(L$) MOD 8): L$ = L$ + sp$: WEND
- Text$ = L$ + R$
- EndLoop
- EndProcedure
-
-
-
- Procedure RemoveTrailingWhiteSpace
- WHILE RIGHT$(Text$,1) = sp$
- Text$ = LEFT$(Text$,LEN(Text$)-1)
- WEND
- EndProcedure
-
-
-
- Procedure PrintLine
- If Text$=""
- MakePrintLine
- LinesLeft=LinesLeft-1
- If fnValidPage
- PRINT# OutputChannel,NewLine$;
- PrintBlankLines
- EndIf
- ElseIf LEN(Text$) <= AvailableSpace
- MakePrintLine
- LinesLeft=LinesLeft-1
- If fnValidPage
- PrintLeftMargin
- PRINT# OutputChannel,Text$;NewLine$;
- PrintBlankLines
- EndIf
- ELSE
- MakePrintLine
- t$=MID$(Text$,1,AvailableSpace)
- Text$=MID$(Text$,AvailableSpace+1,LEN(Text$)-AvailableSpace)
- If fnValidPage
- PrintLeftMargin
- PRINT# OutputChannel,t$;NewLine$;
- PrintBlankLines
- EndIf
- ExitProcedure IF MarginSize = 0
- LinesLeft=LinesLeft-1
- WHILE LEN(Text$) >AvailableSpace
- MakePrintLine
- t$=MID$(Text$,1,AvailableSpace)
- Text$=MID$(Text$,AvailableSpace+1,LEN(Text$)-AvailableSpace)
- If fnValidPage
- PrintOverflowMargin
- PRINT# OutputChannel,t$;NewLine$;
- PrintBlankLines
- EndIf
- LinesLeft=LinesLeft-1
- WEND
- If Text$<>""
- MakePrintLine
- If fnValidPage
- PrintOverflowMargin
- PRINT# OutputChannel,Text$;NewLine$;
- PrintBlankLines
- EndIf
- LinesLeft=LinesLeft-1
- EndIf
- EndIf
- EndProcedure
-
-
-
- Procedure MakePrintLine
- ExitProcedure IF LinesLeft > 0
- EjectPage
- PrintHeader
- EndProcedure
-
-
-
- Procedure EjectPage
- IF fnValidPage THEN PRINT# OutputChannel,NewPage$;
- EndProcedure
-
-
-
- Procedure PrintBlankLines
- ExitProcedure IF BlankLineCount = 0
- FOR i = 1 TO BlankLineCount
- MakePrintLine
- If fnValidPage
- PRINT# OutputChannel,NewLine$;
- EndIf
- LinesLeft = LinesLeft - 1
- NEXT
- EndProcedure
-
-
-
- Procedure InitializePrinter
- ON ERROR GOTO PrinterNotFound@
- OPEN "OUTPUT",#OutputChannel,"LPT1:"
- ON ERROR GOTO ErrorHandler@
- WIDTH #OutputChannel,255 'Suppress automatic line folding on printer.
- CheckPaperEnd$ = esc$ + "9"
- IgnorePaperEnd$ = esc$ + "8"
- Wide$ = CHR$(14)
- Compressed$ = CHR$(15)
- DoubleStrike$ = esc$ + "G"
- Superscript$ = esc$ + "S" + CHR$(1)
- NewLine$ = cr$
- NewPage$ = ff$
-
- RestorePrinter
-
- Mode$ = ""
- If LinesPerPage = 99
- Mode$ = SuperScript$ + Compressed$
- ElseIf LinesPerPage = 108
- Mode$ = SuperScript$ + Compressed$
- ElseIf LinesPerPage = 132
- Mode$ = SuperScript$ + Compressed$
- ElseIf LinesPerPage = 165
- Mode$ = SuperScript$ + Compressed$
- ElseIf CharactersPerLine = 40
- Mode$ = Wide$
- NewLine$ = NewLine$ + Wide$
- NewPage$ = NewPage$ + Wide$
- ElseIf CharactersPerLine = 66
- Mode$ = Wide$+Compressed$
- NewLine$ = NewLine$ + Wide$
- NewPage$ = NewPage$ + Wide$
- ElseIf CharactersPerLine = 80
- Mode$ = ""
- ElseIf CharactersPerLine = 132
- Mode$ = Compressed$
- Else
- PRINT STR$(CharactersPerLine);" characters per line not supported."
- PRINT " Support available for 40, 66, 80, and 132 characters per line."
- SYSTEM
- EndIf
- SetMode
-
- If LinesPerPage = 11
- CALL SetLinesPerInch(1)
- ElseIf LinesPerPage = 22
- CALL SetLinesPerInch(2)
- ElseIf LinesPerPage = 33
- CALL SetLinesPerInch(3)
- ElseIf LinesPerPage = 44
- CALL SetLinesPerInch(4)
- ElseIf LinesPerPage = 66
- CALL SetLinesPerInch(6)
- ElseIf LinesPerPage = 88
- CALL SetLinesPerInch(8)
- ElseIf LinesPerPage = 99
- Mode$ = Mode$ + esc$+"3"+CHR$(24)
- ElseIf LinesPerPage = 108
- Mode$ = Mode$ + esc$+"3"+CHR$(22)
- ElseIf LinesPerPage = 132
- Mode$ = Mode$ + esc$+"3"+CHR$(18)
- ElseIf LinesPerPage = 165
- Mode$ = Mode$ + esc$+"3"+CHR$(14)
- Else
- PRINT STR$(LinesPerPage);" lines per page is not supported."
- PRINT " Values supported: 11, 22, 33, 44, 66, 88, 99, 108, 132, and 165."
- PRINT " The Graphics Printer is required for 99, 108, 132, and 165."
- SYSTEM
- EndIf
- IF NOT GapSpecified THEN InterpageGap = LinesPerPage\11
- PRINT# OutputChannel,Mode$;
-
- AvailableSpace = CharactersPerLine - (MarginSize + RightMarginSize)
- If AvailableSpace <= 0
- PRINT "Characters per line =";STR$(CharactersPerLine);
- PRINT "Left margin size =";STR$(MarginSize)
- PRINT "Right margin size =";STR$(RightMarginSize)
- PRINT "No columns available for text."
- SYSTEM
- EndIf
-
- If InterpageGap > 0
- AvailableLines = LinesPerPage - InterPageGap
- If AvailableLines <= 0
- PRINT "Lines per page =";STR$(LinesPerPage)
- PRINT "Interpage gap =";STR$(InterPageGap)
- PRINT "No lines available for text."
- SYSTEM
- EndIf
- Else
- AvailableLines = 32767
- EndIf
- EndProcedure
-
-
-
- PrinterNotFound@
- PRINT: PRINT "Printer LPT1: cannot be opened."
- SYSTEM
-
-
-
- Procedure SetMode
- If LinesPerPage <= 88
- IF DoubleStrikeSpecified THEN Mode$ = Mode$ + DoubleStrike$
- EndIf
- EndProcedure
-
-
-
- SUB SetLinesPerInch(n) STATIC
- SHARED esc$,Mode$
- Mode$ = Mode$+esc$+"A"+CHR$(72\n)+esc$+"2"
- END SUB
-
-
-
- Procedure RestorePrinter
- PRINT# OutputChannel,esc$;"T";
- PRINT# OutputChannel,esc$;"F";
- PRINT# OutputChannel,esc$;"H";
- PRINT# OutputChannel,CHR$(18);
- PRINT# OutputChannel,CHR$(20);
- PRINT# OutputChannel,esc$;"A";CHR$(12);esc$;"2";
- PRINT# OutputChannel,CheckPaperEnd$;
- EndProcedure
-
-
-
- SUB Capitalize(s$) STATIC
- STATIC i,Length
- Length = LEN(s$)
- If LEN(s$) > 0
- FOR i = 1 TO Length
- ch$=MID$(s$,i,1)
- IF "a" <=ch$ AND ch$ <= "z" THEN MID$(s$,i,1)=chr$(asc(ch$)-32)
- NEXT
- EndIf
- END SUB
-
-
-
- ErrorHandler@
- BEEP
- PRINT
- If ERR = 24 OR ERR = 25 OR ERR = 27
-
- Repeat
- SecondsSinceMidnight! = TIMER
- Until SecondsSinceMidnight! < 86300! 'Avoid clock roll-over
- TimeToAbort! = SecondsSinceMidnight! + 60
-
- PRINT "Printer is off or out of paper."
- PRINT "Please do not turn off the power if it is already on."
- PRINT "Currently on page";STR$(CurrentPage)
- If NOT OperatorIsPresent
- PRINT "Starting 60-second time-out before terminating."
- PRINT "If you elect to continue, you will be given as"
- PRINT "much time as necessary to prepare the printer."
- PRINT
- EndIf
- COLOR 0,7: PRINT " C)ontinue or Q)uit? ";: COLOR 7,0
- LOCATE ,,1
- Repeat
- Repeat
- If TIMER > TimeToAbort! AND NOT OperatorIsPresent
- LOCATE ,1,0: PRINT " ";: LOCATE ,1,0
- COLOR 0,7: PRINT " 60-second time out. ";: COLOR 7,0
- PRINT
- SomeString$ = "Q"
- Else
- SomeString$ = INKEY$
- EndIf
- Until LEN(SomeString$) <> 0
- CALL Capitalize(SomeString$)
- Until INSTR("CQ",SomeString$) > 0
- If SomeString$ = "C"
- OperatorIsPresent = TRUE
- EnterMsg$ = " Press ENTER when ready... "
- LOCATE ,1,0: COLOR 0,7: PRINT EnterMsg$;: COLOR 7,0: LOCATE ,,1
- Repeat
- Until INKEY$ = cr$
- LOCATE ,1,0: PRINT SPACE$(LEN(EnterMsg$));: LOCATE ,1,0
- PRINT# OutputChannel,Mode$;
- RESUME
- Else
- PRINT "Q"
- PRINT "If the printer is on, it may require resetting."
- PRINT "To do so, turn it off, adjust top of form, and turn it back on."
- SYSTEM
- EndIf
- EndIf
-
- RestorePrinter
- CALL BASICERR(ErrorMsg$)
- PRINT
- PRINT "Error";STR$(ERR);" on line";STR$(ERL)
- PRINT ErrorMsg$
- SYSTEM
-
-
-
- SUB BASICERR(ErrorMsg$) STATIC
- If ERR = 2
- ErrorMsg$ = "Syntax error"
- ElseIf ERR = 3
- ErrorMsg$ = "RETURN without GOSUB"
- ElseIf ERR = 4
- ErrorMsg$ = "Out of DATA"
- ElseIf ERR = 5
- ErrorMsg$ = "Illegal function call"
- ElseIf ERR = 6
- ErrorMsg$ ="Overflow"
- ElseIf ERR = 7
- ErrorMsg$ = "Out of memory"
- ElseIf ERR = 9
- ErrorMsg$ = "Subscript out of range"
- ElseIf ERR = 11
- ErrorMsg$ = "Division by zero"
- ElseIf ERR = 13
- ErrorMsg$ = "Type mismatch"
- ElseIf ERR = 14
- ErrorMsg$ = "Out of string space"
- ElseIf ERR = 16
- ErrorMsg$ = "String formula too complex"
- ElseIf ERR = 19
- ErrorMsg$ = "No RESUME"
- ElseIf ERR = 20
- ErrorMsg$ = "RESUME without error"
- ElseIf ERR = 24
- ErrorMsg$ = "Device Timeout"
- ElseIf ERR = 25
- ErrorMsg$ = "Device Fault"
- ElseIf ERR = 27
- ErrorMsg$ = "Out of paper"
- ElseIf ERR = 50
- ErrorMsg$ = "FIELD overflow"
- ElseIf ERR = 51
- ErrorMsg$ = "Internal error"
- ElseIf ERR = 52
- ErrorMsg$ = "Bad file number"
- ElseIf ERR = 53
- ErrorMsg$ = "File not found"
- ElseIf ERR = 54
- ErrorMsg$ = "Bad file mode"
- ElseIf ERR = 55
- ErrorMsg$ = "File already open"
- ElseIf ERR = 57
- ErrorMsg$ = "Device I/O Error"
- ElseIf ERR = 58
- ErrorMsg$ = "File already exists"
- ElseIf ERR = 61
- ErrorMsg$ = "Disk full"
- ElseIf ERR = 62
- ErrorMsg$ = "Input past end"
- ElseIf ERR = 63
- ErrorMsg$ = "Bad record number"
- ElseIf ERR = 64
- ErrorMsg$ = "Bad file name"
- ElseIf ERR = 67
- ErrorMsg$ = "Too many files"
- ElseIf ERR = 68
- ErrorMsg$ = "Device unavailable"
- ElseIf ERR = 69
- ErrorMsg$ = "Communication buffer overflow"
- ElseIf ERR = 70
- ErrorMsg$ = "Permission Denied"
- ElseIf ERR = 71
- ErrorMsg$ = "Disk not Ready"
- ElseIf ERR = 72
- ErrorMsg$ = "Disk Media Error"
- ElseIf ERR = 73
- ErrorMsg$ = "Advanced Feature"
- ElseIf ERR = 74
- ErrorMsg$ = "Rename Across Disks"
- ElseIf ERR = 75
- ErrorMsg$ = "Path/file access error"
- ElseIf ERR = 76
- ErrorMsg$ = "Path not found"
- Else
- ErrorMsg$ = "Error"+STR$(ERR)+" (unclassified error)."
- EndIf
- END SUB